package com.winning.dps.rda.common.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;


/**
 * 访问地址：http://localhost:8081/bms/swagger-ui.html
 */
@Configuration
@EnableSwagger2
public class Swagger2Config {


  @Bean
  public Docket docket() {
    return new Docket(DocumentationType.SWAGGER_2)
        .apiInfo(apiInfo())
        .enable(true)
        .groupName("v2")
        .select()
        // 过滤路径
        .paths(PathSelectors.any())
        // 指定扫描的包
        .apis(RequestHandlerSelectors.basePackage("com.winning.dps.rda.standardManage.controller"))
        .build();
  }

  private ApiInfo apiInfo() {

    Contact contact =
        new Contact(
            "Strive", "", "");
    return new ApiInfo(
        "基础管理系统测试接口文档",
        "基础平台restful api 文档",
        "v1.0",
        "",
        contact,
        "",
        "",
        new ArrayList());
  }
}
